<?php include "session.php" ?>
<?php
	include ("config/koneksi.php");
	$no_kembali=$_POST['no_kembali'];
	$tgl_kembali=$_POST['tgl_kembali'];
	$no_sewa=$_POST['no_sewa'];
	$username=$_POST['username'];
	
	$sqlTampil = "SELECT * FROM tbl_pinjam WHERE no_sewa='$no_sewa'";
  	$queryTampil = mysql_query($sqlTampil, $connect) or die ("Gagal query ".mysql_error());
  
  	while($dataTampil=mysql_fetch_array($queryTampil)) {
		$kd_brg = $dataTampil['kd_brg'];	
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="style/style.css" />
    <title>Inventaris IT DMA</title>
</head>
<body>
    <center><div class="header"><?php include "header.php" ?></div></center>
    <center><div id="clock"><?php include "js/tanggal.html" ?><?php include "js/jam.html" ?></div></center>
	<center><div class="navbar"><?php include "navBar.php"; ?></div></center>
    <center><div id="right">
    	<!-- AWAL PROSES INPUT -->
    	<br /><br /><br />
    	<?php
			$query = mysql_query("INSERT INTO tbl_kembali VALUES  ('$no_kembali','$no_sewa','$tgl_kembali','$username')");
			
			$sqlUbah = "UPDATE tbl_pinjam SET status='Sudah Dikembalikan' WHERE no_sewa='$no_sewa'";
			mysql_query($sqlUbah, $connect) or die ("Gagal perintah SQL ".mysql_error());
			
			$sqlUbah = "UPDATE tbl_barang SET status='Ada' WHERE kd_brg='$kd_brg'";
			mysql_query($sqlUbah, $connect) or die ("Gagal perintah SQL ".mysql_error());
			
			echo "Data transaksi telah disimpan<br><br>
			<a href=\"transaksiPengembalianAdd.php\"><img src=img/back.png width=50 height=50 title=Kembali></a>";
		?>
    	<!-- AKHIR PROSES INPUT -->
    </div></center>
    <center><div class="footer"><?php include "footer.php" ?></div></center>
</body>
</html>